package com.jydd.liaomingframe.lrucache;

import com.hzh.easy.cache.base.BaseCache;
import com.hzh.easy.cache.util.ACache;

import java.io.Serializable;

/**
 * created by 韦敏敏
 * on 2019/11/26
 * 用户信息缓存
 */
public class UserInfoCache extends BaseCache<UserInfoCacheParam> {
    /*保存的唯一判断标准*/
    private static final String KEY = "cache_user_id_";
    // 缓存时间，保存7天
    private static final int SAVE_TIME = 7 * ACache.TIME_DAY;
    @Override
    public void removeCache(UserInfoCacheParam params) {
        getOperate().removeCache(KEY + params.getUserId());
    }
    @Override
    public void put(UserInfoCacheParam params, Serializable target) {
        getOperate().putData(params.getUserId(), target, SAVE_TIME);
    }
    @Override
    public <T extends Serializable> T get(UserInfoCacheParam params) {
        return getOperate().getData(params.getUserId(), null);
    }
}
